import requests
import json

sql = "SELECT price FROM goods WHERE sku_name LIKE '%施巴清爽润肤乳%'"
# data = {"sql":sql}
data = {"sql": "SELECT COUNT(id) FROM goods"}
url = 'http://127.0.0.1:5000/query'
# 创建连接池管理器
# http = urllib3.PoolManager()
# 编码请求数据
json_data = json.dumps(data).encode('utf-8')
print(json_data)


# 发送 POST 请求
response = requests.post(
    url=url,
    headers={'Content-Type': 'application/json'},
    data=json_data
)


# 检查响应状态（可选，但推荐）
if response.status_code != 200:
    raise Exception(f"请求失败，状态码: {response.status_code}")
# 解析响应数据
response_data = response.content.decode('utf8')
decoded_list = json.loads(response_data)

# 将解码后的列表作为值，生成一个以 'result' 为键的字典
result_dict = {'result': decoded_list}
print(result_dict)
# 打印结果
# print(result_dict)
 
